﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GcmpCommonEdit.h"
#include "IObject.h"
#include "OwnerPtr.h"

namespace gcmp
{
    class IInteractionEventHandler;
    class IInteractionEvent;
    class IInteractionEventArgs;
    class IElement;
    class UniIdentity;

    /// \brief 交互事件管理器，用于管理对应的element和交互事件的处理器
    class GCMP_COMMON_EDIT_EXPORT IInteractionEventManager : public IObject
    {
        DEFINE_CAST_DERIVED(IInteractionEventManager, IObject);
    public:
        static IInteractionEventManager* Get();
    public:
        /// \brief 添加交互事件处理器
        ///
        /// \param elementImplementationUid Element实现类别的Uid
        /// \param eventTypeId 事件类型的Id
        /// \param opHandler 交互事件处理器
        /// \return 如果添加成功返回true，否则false
        virtual bool AddHandler(const UniIdentity& elementImplementationUid, 
            const std::wstring& eventTypeId, OwnerPtr<IInteractionEventHandler> opHandler) = 0;

        /// \brief 删除交互事件处理器
        ///
        /// \param elementImplementationUid Element实现类别的Uid
        /// \param eventTypeId 事件类型的Id
        /// \return 如果删除成功返回true，否则false
        virtual bool DeleteHandler(const UniIdentity& elementImplementationUid, 
            const std::wstring& eventTypeId) = 0;

        /// \brief 查询是否已经绑定处理器
        ///
        /// \param elementImplementationUid Element实现类别的Uid
        /// \param eventTypeId 事件类型的Id
        /// \return 如果已经绑定返回true，否则返回false
        virtual bool HasHandler(const UniIdentity& elementImplementationUid,
            const std::wstring& eventTypeId) const = 0;

        /// \brief 事件执行
        ///
        /// \param pArgs 事件执行参数
        virtual void Execute(IInteractionEventArgs* pArgs) = 0;
    };
}